
var dbase;

function init()
{
	dbase = _server.getDatabaseManager();
}

function destroy()
{
	
}

function handleRequest(cmd, params, user, fromRoom)
{
	switch(cmd){
		case "message_get_person_info_cmd":
			getPersonInfo(cmd, params, user, fromRoom);//获取个人信息
			break;
	}
}

function handleInternalEvent(evt)
{
	
}

/**
 * 获取自己的属性信息
 * @param cmd
 * @param params
 * @param user
 * @param fromRoom
 * @return 
 * 
 */
function getPersonInfo(cmd, params, user, fromRoom){
	
	var t1 = getTimer()
	
	var sql = "SELECT * FROM pvs.users where userNumber="+params.userNumber;
	var queryRes = dbase.executeQuery(sql)
	
	var t2 = getTimer()
	trace("DB Request took: " + (t2-t1) + " ms.")
	
	var response = {}
	response._cmd=cmd
	
	if (queryRes != null)
	{
		var tempRow = queryRes.get(0)
		response.userNumber		= tempRow.getItem("userNumber");
		response.username		= tempRow.getItem("username");
		response.nickname		= tempRow.getItem("nickname");
		response.level			= tempRow.getItem("level");
		response.exp 			= tempRow.getItem("exp");
		response.PVcoins		= tempRow.getItem("PVcoins");
		response.birthday 		= tempRow.getItem("birthday");
		response.qq				= tempRow.getItem("qq");
		response.phoneNumber 	= tempRow.getItem("phoneNumber");
		response.province 		= tempRow.getItem("province");
		response.sex 			= tempRow.getItem("sex");
		response.department		= tempRow.getItem("department");
		response.userClass		= tempRow.getItem("class");
		/*response.pic 			= tempRow.getItem("pic");
		response.clothes 		= tempRow.getItem("clothes");
		response.association	= tempRow.getItem("association");
		response.onlineTime		= tempRow.getItem("onlineTime");
		response.buddyList		= tempRow.getItem("buddyList");*/
		
		//response.db.push( item );
		//}
	}
	else
	{
		trace("DB Query failed");
	}
	_server.sendResponse(response, -1, null, [user],"xml");
}